package com.kirk.cts.ui.view.panel;

import com.kirk.cts.core.event.CrawlerToolObserver;
import org.apache.log4j.Logger;

import javax.swing.*;
import java.awt.*;

/**
 * <p> AbstractTabPanel.java </p>
 *
 * @version 1.0.0
 * @Author kirkliu
 * @Date 2020-09-01 23:18
 * @Description TabPanel接口抽象实现类
 */
public abstract class AbstractTabPanel extends JPanel implements ITabPanel {
    private static final long serialVersionUID = 1L;
    protected Logger logger = Logger.getLogger(this.getClass());
    private boolean hasInit = false;

    protected AbstractTabPanel() {
        super();
    }

    public void init() {
        if (!hasInit) {
            BorderLayout layout = new BorderLayout();
            this.setLayout(layout);
            this.add(getCenterPanel(), BorderLayout.CENTER);
            CrawlerToolObserver.getInstance().addCrawlerListener(this);
            hasInit = true;
        }
        initOther();
    }

    public JPanel getPanel() {
        return this;
    }

    /**
     * 取得中间面板组件
     */
    protected abstract Component getCenterPanel();

    /**
     * 初始化其他
     */
    protected void initOther() {
    }
}
